
interface config {
  method: string
  headers?: HeadersInit
  body?: BodyInit
  mode?: RequestMode
}

// export const baseUrl = 'http://82.156.215.210:3000/mock/14/applet'
export const baseUrl = 'https://www.zichin.com/mock/14/applet'
export const headers = new Headers({
  'Access-Control-Allow-Origin': '*',
  "Content-Type": 'text/plain'
})
export const postConfig = {
  method: 'POST',  // 写请求方法
  headers: {
    // 配置请求头
    // 例如: "Content-Type": 'application/json'
  },
  body: {
    // 配置请求体, 比如POST请求要传递的数据
  }
}
export const getConfig: config = {
  method: 'GET',
  mode: 'cors',
  headers: {
    'Access-Control-Allow-Origin': '*'
  },
}



export const getNavList = () => {
  const url = `${baseUrl}/getNavList`
  return fetch(url, getConfig) // 开始请求数据
    .then(res => res.json())
}

export const getNativeNavList = () => {
  // fetch获取本地json文件是相对public中的index.html的
  const url = './static/data/getNavList.json'
  return fetch(url)
    .then(res => res.json())
}